import bpy

import 全局控制.Node.节点和插座基类.bl_节点基类 as 基类

import Core.bl_UI配色 as UI配色

import engine.initLIB.load_dll as engineLib
import ctypes



engineLib.flexCAPI.f_创建BVH节点.restype = ctypes.c_bool










class C_Node_BVH(基类.C_Node_基类):
	bl_dname = 'bl_node_运算'
	bl_label = 'BVH'
	
	def init(self, context):
		super(C_Node_BVH, self).f_init(context)
		self.inputs.new('C_Socket_Vec3_Array1D', name='坐标')
		self.inputs.new('C_Socket_网格', name='网格')
		self.inputs.new('C_Socket_Vec3', name='间隔')

		self.outputs.new('C_Socket_Uint64Key_UInt32_Array1D', name='坐标键值索引')
		self.outputs.new('C_Socket_iVec3_Array1D', name='键值')
		self.f_toCPP()

		self.inputs['间隔'].f_setData((1.0,1.0,1.0))



	def draw_buttons(self, context, layout):
		pass

	def f_toCPP(self):
		是否更新 = engineLib.flexCAPI.f_创建BVH节点(ctypes.c_wchar_p(self.id_data.name), ctypes.c_wchar_p(self.name), self.f_getPyObject());
		if 是否更新 :
			self.inputs['间隔'].f_update()

class C_MENU_Add_BVH(bpy.types.Operator):
	bl_idname = 'node.add_bvh_node'
	bl_label = 'BVH'
	#bl_options = {'REGISTER', 'UNDO'}
	def execute(operator, context):
		bpy.ops.node.add_node(type='C_Node_BVH', use_transform=True)
		return {'FINISHED'}








classes = (
	C_Node_BVH,
	C_MENU_Add_BVH,
)

def register():
	for c in classes:
		bpy.utils.register_class(c)
		
def unregister():
	for c in classes:
		bpy.utils.unregister_class(c)

	
